package com.tetris.entities;

import java.util.Random;

public class ShapeFactory {

	private ShapeData[] shapeData = new ShapeData[]{
		new ShapeData(3, new int[][]{
			{0, 1, 1},
			{0, 1, 0},
			{0, 1, 0}
		}, 4),
		new ShapeData(3, new int[][]{
			{1, 1, 0},
			{0, 1, 0},
			{0, 1, 0}
		}, 4),
		new ShapeData(3, new int[][]{
			{0, 1, 0},
			{1, 1, 1},
			{0, 0, 0}
		}, 4),
		new ShapeData(4, new int[][]{
			{0, 0, 1, 0},
			{0, 0, 1, 0},
			{0, 0, 1, 0},
			{0, 0, 1, 0}
		}, 4),
		new ShapeData(2, new int[][]{
			{1, 1},
			{1, 1}
		}, 1),
		new ShapeData(3, new int[][]{
			{0, 1, 1},
			{1, 1, 0},
			{0, 0, 0}
		}, 4),
		new ShapeData(3, new int[][]{
			{1, 1, 0},
			{0, 1, 1},
			{0, 0, 0}
		}, 4)
	};

	public Shape getShape(){
		Shape shape = new Shape();
		int type = new Random().nextInt(shapeData.length);
		shape.setShapeData(shapeData[type]);
		shape.setStatus( new Random().nextInt(shapeData[type].getData().length) );	//图形下落是形状随机
		return shape;
	}
}
